<?php
/* @var $model Profile */
$this->pageHeader = t('LBL_TRANSLATE_PROFILE',  'profile');
$this->pageTitle = t('LBL_TRANSLATE_PROFILE','profile');
$logedInUser = User::model()->findByPk(Yii::app()->user->id);
$toolbar = new LGToolbar();
$toolbar->ButtonSave(t('BTN_SAVE', 'profile'), '#translate-form', ActionType::SAVE);

if ($logedInUser->isEditor() || $logedInUser->isAdmin() || $logedInUser->isSuperAdmin()){    
    $toolbar->buttonNewPage(t ( 'PAGE_TITLE_ADDNEW', 'advanceProfile' ), '', 'advanceprofile/index/', array('id'=>$model->id));
}

if ($model->status !=ProfileStatus::STATUS_NEW){
	$toolbar->buttonNewPage(t('BTN_REJECT','profile'), '', 'profile/reject', array('id'=>$model->id));
	$toolbar->ButtonSave(t('BTN_TRANSLATED','profile'), '#translate-form', ActionType::SUBMIT);
}
$toolbar->buttonDetail(t('BTN_DETAIL','profile'), t('BTN_DETAIL','profile'), 'buttonDetail', '', "translate/detail", array("id" => $model->id,"alias"=>stringURLSafe($model->full_name)));
$toolbar->Cancel('btnCancel',t('BTN_CANCEL'),url('/profile/'));
$this->pageToolbar = $toolbar->mergeToolbar();
$flagDate = 'dvalid';
if(isset($translatedModel->update_date))
{
	$date1 = new DateTime($model->update_date);
	$date2 = new DateTime($translatedModel->update_date);
	$flagDate = ($date1 <= $date2) ? 'dvalid' : 'dinvalid';
}
else
{
	$flagDate = 'dinvalid';
}
?>
<div class="moreinfo">
	<table>
		<tr>
			<td>Trạng thái: <?php echo t("STATUS_" . $model->status, "profile"); ?></td>
			<td style="width: 50px;"></td>
			<td><?php echo t("HEADER_UPDATE_DATE", "history"); ?></td>
			<td><span><?php echo $model->update_date; ?></span></td>				
			<td style="width: 50px;"></td>
			<td><?php echo t("HEADER_TRANSLATE_DATE", "history"); ?></td>
			<td><span class="<?php echo $flagDate ?>"><?php echo (isset($translatedModel->update_date))? $translatedModel->update_date : 'Hồ sơ chưa được dịch lần nào'; ?></span></td>			
		</tr>
	</table>
</div>
<?php    
	unset($date1,$date2,$flagDate);    
	$this->renderPartial('_form', array('model' => $model, 'translatedModel' => $translatedModel));
?>